package com.miracle.main.module.api;

import com.miracle.basemvp.base.BaseResponse;
import com.miracle.common.mvp.entity.response.BaseListResponse;
import com.miracle.common.mvp.entity.response.DandelionResponse;
import com.miracle.common.mvp.entity.response.VersionInfo;
import com.miracle.main.module.mvp.entity.bean.FileItem;
import com.miracle.main.module.mvp.entity.request.FileListRequest;

import java.util.ArrayList;

import io.reactivex.Observable;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.Part;
import retrofit2.http.Streaming;
import retrofit2.http.Url;

/**
 * com.miracle.main.module.api
 * (c)2018 AIR Times Inc. All rights reserved.
 *
 *
 * @author WangJQ
 * @version 1.0
 * @date 2018/7/7 13:36
 * @see com.miracle.main.module.api
 */
public interface MainApi {

    /**
     * 获取最新版本
     * @param
     * @return
     */
    @FormUrlEncoded
    @POST("https://www.pgyer.com/apiv2/app/check")
    Observable<DandelionResponse<VersionInfo>> checkVersion(@Field("_api_key") String apiId,
                                                            @Field("appKey") String appkey);

    @Streaming //大文件时要加不然会OOM
    @GET
    Call<ResponseBody> downloadFile(@Url String fileUrl);

    @POST
    Observable<ResponseBody> uploadFile(@Url String url, @Body MultipartBody body);

    @POST("getList")
    Observable<BaseResponse<BaseListResponse<FileItem>>> getFileList(@Body FileListRequest request);

    /**
     * 上传头像
     * @param url
     * @param body
     * @return
     */
    @POST
    Observable<ResponseBody> uploadTx(@Url String url, @Body MultipartBody body);
}
